package cn.tedu._05springaop.aop;

import org.springframework.stereotype.Component;

@Component
public class CalculatorImpl implements Calculator{
    @Override
    public int add(int a, int b) {
        try {
            if(a>0){
                throw new RuntimeException("a不能大于0");
            }
        } catch (RuntimeException e) {
//            e.printStackTrace();
            System.out.println("a不能大于0");
        }
        int result = a + b;
        System.out.println("a+b=" + result);
        return result;
    }

    @Override
    public int sub(int a, int b) {
        int result = a - b;
        System.out.println("a-b=" + result);
        return result;
    }

    @Override
    public int mul(int a, int b) {
        int result = a * b;
        System.out.println("a*b=" + result);
        return result;
    }

    @Override
    public int div(int a, int b) {
        int result = a / b;
        System.out.println("a/b=" + result);
        return result;
    }
}
